﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StuLib
{
    public class Student
    {
        // 统计学生人数
        private static int count = 0;

        public Student()
        {
            count++;
        }

        public Student(string sname, string sno, int age): this()
        {
            SName = sname;
            Sno = sno;
            Age = age;
        }
        // 析构函数
        ~Student()
        {
            string fmt = "学号：{1}被删除，执行析构函数！";
            string.Format(fmt, SName, Sno, Age);
            Console.WriteLine(fmt);
            count--;
        }
       

        public string SName
        {
            get;
            set;
        }

        public string Sno
        {
            get;
            set;
        }

        public int Age
        {
            get;
            set;
        }

        public string SayHi
        {
            get
            {
                string fmt = "我是：{0}, 学号：{1}， 今年{2}岁";
                return string.Format(fmt, SName, Sno, Age);
            }
        }
        public static int getCount()
        {
            return count;
        }
        public override string ToString()
        {
            return "Sno:"+ Sno + ", SName:"+ SName + ", Age:" + Age;
        }
    }
}
